package com.jacobson.huobi.mvp.model

import com.alibaba.fastjson.JSONObject
import com.jacobson.core.di.annotation.ActivityScope
import com.jacobson.core.framework.repository.IRepositoryManager
import com.jacobson.core.mvp.BaseModel
import com.jacobson.huobi.api.VipRechargeApi
import com.jacobson.huobi.entities.VipRechargeCostInfo
import com.jacobson.huobi.entities.evt.VipRechargeSubmitEvt
import com.jacobson.huobi.entities.response.CommonResponse
import com.jacobson.huobi.entities.response.VipRechargeResponse
import com.jacobson.huobi.mvp.contract.VipContract
import io.reactivex.Observable
import okhttp3.MultipartBody
import javax.inject.Inject

@ActivityScope
class VipModel @Inject constructor(
    repositoryManager: IRepositoryManager
) : BaseModel(repositoryManager), VipContract.Model {

    private val vipRechargeApi =
        repositoryManager.obtainRetrofitService(VipRechargeApi::class.java)

    override fun loadRechargeSupportList(vipLevel: Int): Observable<VipRechargeResponse> {
        return vipRechargeApi.loadRechargeSupportList(vipLevel)
    }

    override fun loadRechargeCost(rechargeSupportId: Int): Observable<CommonResponse<VipRechargeCostInfo>> {
        return vipRechargeApi.loadRechargeCost(rechargeSupportId)
    }

    override fun vipUpload(
        file: MultipartBody.Part,
        width: Int
    ): Observable<CommonResponse<JSONObject>> {
        return vipRechargeApi.vipUpload(file, width = 150)
    }

    override fun rechargeSubmit(rechargeSubmitEvt: VipRechargeSubmitEvt): Observable<CommonResponse<JSONObject>> {
        return vipRechargeApi.rechargeSubmit(rechargeSubmitEvt)
    }


}